# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=pygobject
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-gobject")
pkgver=3.40.1
pkgrel=1
pkgdesc="Python Bindings for GLib/GObject/GIO/GTK+ (mingw-w64)"
arch=(any)
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url="https://pygobject.readthedocs.io"
license=('LGPL')
depends=("${MINGW_PACKAGE_PREFIX}-glib2"
         "${MINGW_PACKAGE_PREFIX}-python-cairo"
         "${MINGW_PACKAGE_PREFIX}-libffi"
         "${MINGW_PACKAGE_PREFIX}-gobject-introspection-runtime")
makedepends=("${MINGW_PACKAGE_PREFIX}-python"
             "${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-ninja"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection")
provides=("${MINGW_PACKAGE_PREFIX}-pygobject-devel"
          "${MINGW_PACKAGE_PREFIX}-python3-gobject=${pkgver}")
conflicts=("${MINGW_PACKAGE_PREFIX}-pygobject-devel"
           "${MINGW_PACKAGE_PREFIX}-python3-gobject")
replaces=("${MINGW_PACKAGE_PREFIX}-pygobject-devel"
          "${MINGW_PACKAGE_PREFIX}-python3-gobject")
source=(https://download.gnome.org/sources/pygobject/${pkgver%.*}/${_realname}-${pkgver}.tar.xz)
sha256sums=('00c6d591f4cb40c335ab1fd3e8c17869ba15cfda54416fe363290af766790035')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
}

build() {
  [[ -d build-${MINGW_CHOST} ]] && rm -rf build-${MINGW_CHOST}
  mkdir -p build-${MINGW_CHOST} && cd build-${MINGW_CHOST}

  MSYS2_ARG_CONV_EXCL="--prefix=" \
  meson \
    --prefix="${MINGW_PREFIX}" \
    --wrap-mode=nodownload \
    --auto-features=enabled \
    --buildtype=plain \
    ../${_realname}-${pkgver}

  meson compile
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"

  DESTDIR="${pkgdir}" meson install
}
